package com.theima.socket.socketdemo5;

import javax.xml.crypto.Data;
import java.io.IOException;
import java.net.*;

/**
 * @program: Myset
 * @description: 广播代码实现
 * @author: xuejingjing
 * @create: 2021-06-25 22:05
 **/
public class ClientDemo {
    public static void main(String[] args) throws IOException {

        DatagramSocket  ds = new DatagramSocket();

        String s = "广播 hello";
        byte[] bytes = s.getBytes();
        InetAddress address = InetAddress.getByName("255.255.255.155");
        int port = 10000;
        DatagramPacket dp = new DatagramPacket(bytes,bytes.length,address,port);

        ds.send(dp);

        ds.close();


    }
}
